<?php

namespace tkan\models;

use Yii;

/**
 * This is the model class for table "fond_item".
 *
 * @property int $id
 * @property string $title
 * @property string|null $short_description
 * @property string|null $full_description
 * @property string|null $tabular_data
 * @property string|null $prev_img
 * @property string|null $gallery_img
 * @property int $id_fond_collection
 *
 * @property FondCollection $fondCollection
 */
class FondItem extends \yii\db\ActiveRecord
{
    public $imageForCover;
    public $imagesForGallery;
    
    const BUCKET_NAME = 'ogikm-img-fond';

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'fond_item';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title', 'id_fond_collection'], 'required'],
            [['full_description', 'tabular_data'], 'string'],
            [['id_fond_collection'], 'integer'],
            [['title', 'gallery_img'], 'string', 'max' => 255],
            [['short_description'], 'string', 'max' => 1024],
            [['prev_img'], 'string', 'max' => 45],
            [['id_fond_collection'], 'exist', 'skipOnError' => true, 'targetClass' => FondCollection::className(), 'targetAttribute' => ['id_fond_collection' => 'id']],
            [['imageForCover'], 'file', 'extensions' => 'jpg'],
            [['imagesForGallery'], 'file', 'extensions' => 'jpg', 'maxFiles' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => 'Title',
            'short_description' => 'Short Description',
            'full_description' => 'Full Description',
            'tabular_data' => 'Tabular Data',
            'prev_img' => 'Prev Img',
            'gallery_img' => 'Gallery Img',
            'id_fond_collection' => 'Id Fond Collection',
            'imageForCover' => 'Изображение для обложки',
            'imagesForGallery' => 'Изображения для галлереи',
        ];
    }

    /**
     * Gets query for [[FondCollection]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getFondCollection()
    {
        return $this->hasOne(FondCollection::className(), ['id' => 'id_fond_collection']);
    }

}
